package com.byxy.mysystem.service.system.impl;

import com.byxy.mysystem.model.system.SysRequestPath;
import com.byxy.mysystem.mapper.system.SysRequestPathMapper;
import com.byxy.mysystem.service.system.ISysRequestPathService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

import java.util.List;

/**
 * <p>
 * 请求路径 服务实现类
 * </p>
 *
 * @author omd
 * @since 2022-10-07
 */
@Service
public class SysRequestPathServiceImpl extends ServiceImpl<SysRequestPathMapper, SysRequestPath> implements ISysRequestPathService {

    @Override
    public List<SysRequestPath> getResource() {
        List<SysRequestPath> roots = baseMapper.findRoots();
        if(!CollectionUtils.isEmpty(roots)){
            for (SysRequestPath root:roots) {
                List<SysRequestPath> childrens = baseMapper.findChildrens(root.getId());
                root.setChildren(childrens);
            }
        }
        return roots;
    }
}
